<template>
    <view>
        <!--标题和返回-->
		<cu-custom :bgColor="NavBarColor" isBack :backRouterName="backRouteName">
			<block slot="backText">返回</block>
			<block slot="content">异常抽盘明细管理</block>
		</cu-custom>
		 <!--表单区域-->
		<view>
			<form>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">资产名称：</text></view>
                  <input  placeholder="请输入资产名称" v-model="model.assetName"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">资产编码：</text></view>
                  <input  placeholder="请输入资产编码" v-model="model.assetCoding"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">所属人id：</text></view>
                  <input  placeholder="请输入所属人id" v-model="model.ownerId"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">所属人姓名：</text></view>
                  <input  placeholder="请输入所属人姓名" v-model="model.owner"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">使用人id：</text></view>
                  <input type="number" placeholder="请输入使用人id" v-model="model.userId"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">使用人姓名：</text></view>
                  <input  placeholder="请输入使用人姓名" v-model="model.userer"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">资产状态：</text></view>
                  <input  placeholder="请输入资产状态" v-model="model.status"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">主表id：</text></view>
                  <input type="number" placeholder="请输入主表id" v-model="model.applyId"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">部门id：</text></view>
                  <input type="number" placeholder="请输入部门id" v-model="model.deptId"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">部门名称：</text></view>
                  <input  placeholder="请输入部门名称" v-model="model.deptName"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">盘点状态,1 已盘：</text></view>
                  <input  placeholder="请输入盘点状态,1 已盘" v-model="model.inventoryStatus"/>
                </view>
              </view>
              <my-date label="入账日期：" v-model="model.useTime" placeholder="请输入入账日期"></my-date>
              <my-date label="startTime：" v-model="model.startTime" placeholder="请输入startTime"></my-date>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">资产规格：</text></view>
                  <input  placeholder="请输入资产规格" v-model="model.spec"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">待盘数量：</text></view>
                  <input type="number" placeholder="请输入待盘数量" v-model="model.notInventoryQuantity"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">已盘数：</text></view>
                  <input type="number" placeholder="请输入已盘数" v-model="model.inventoryQuantity"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">资产数：</text></view>
                  <input type="number" placeholder="请输入资产数" v-model="model.assetsNum"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">备注：</text></view>
                  <input  placeholder="请输入备注" v-model="model.msgDesc"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">单据唯一值：</text></view>
                  <input  placeholder="请输入单据唯一值" v-model="model.uniqueId"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">类别：</text></view>
                  <input  placeholder="请输入类别" v-model="model.category"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">preliminaryStatus：</text></view>
                  <input type="number" placeholder="请输入preliminaryStatus" v-model="model.preliminaryStatus"/>
                </view>
              </view>
				<view class="padding">
					<button class="cu-btn block bg-blue margin-tb-sm lg" @click="onSubmit">
						<text v-if="loading" class="cuIcon-loading2 cuIconfont-spin"></text>提交
					</button>
				</view>
			</form>
		</view>
    </view>
</template>

<script>
    import myDate from '@/components/my-componets/my-date.vue'

    export default {
        name: "AssetsDoubleQuotationResultItemForm",
        components:{myDate},
        props:{
          formData:{
              type:Object,
              default:()=>{},
              required:false
          }
        },
        data(){
            return {
				CustomBar: this.CustomBar,
				NavBarColor: this.NavBarColor,
				loading:false,
                model: {},
                backRouteName:'index',
                url: {
                  queryById: "/assets/assetsDoubleQuotationResultItem/queryById",
                  add: "/assets/assetsDoubleQuotationResultItem/add",
                  edit: "/assets/assetsDoubleQuotationResultItem/edit",
                },
            }
        },
        created(){
             this.initFormData();
        },
        methods:{
           initFormData(){
               if(this.formData){
                    let dataId = this.formData.dataId;
                    this.$http.get(this.url.queryById,{params:{id:dataId}}).then((res)=>{
                        if(res.data.success){
                            console.log("表单数据",res);
                            this.model = res.data.result;
                        }
                    })
                }
            },
            onSubmit() {
                let myForm = {...this.model};
                this.loading = true;
                let url = myForm.id?this.url.edit:this.url.add;
				this.$http.post(url,myForm).then(res=>{
				   console.log("res",res)
				   this.loading = false
				   this.$Router.push({name:this.backRouteName})
				}).catch(()=>{
					this.loading = false
				});
            }
        }
    }
</script>
